<?php

namespace App\Models;

use Dcat\Admin\Traits\HasDateTimeFormatter;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class ContractTemplate extends Model
{
    use HasDateTimeFormatter;
    use SoftDeletes;
    protected $table = 'contract_template';


    // public function getUrlAttribute($value)
    // {
    //     if ($this->or_url($value)) {
    //         return $value;
    //     } else {
    //         return config('filesystems.disks.qiniu.domains.https') . $value;
    //         //  return storage_path('app/public') . '/' . $value;
    //         // return env('APP_URL')  . '/storage' . '/' . $value;
    //     }
    // }

    /**
     * 判断地址是否是url地址
     *
     * @Author hechengwei
     * @email chichiooo@sina.com
     * @DateTime 2022-04-11
     * @param string $url
     * @return bool
     */
    public function or_url($url)
    {

        if (empty($url)) {
            return true;
        }
        $preg = "/http[s]?:\/\/[\w.]+[\w\/]*[\w.]*\??[\w=&\+\%]*/is";

        if (preg_match($preg, $url)) {

            return true;
        } else {

            return false;
        }
    }
}
